#ifndef __THREADPOOL_H_
#define __THREADPOOL_H_
#include"TaskQueue.h"
#include"Thread.h"
#include<functional>
#include<vector>
#include<memory>

namespace SC
{
    using Task = std::function<void()>;

    class Threadpool
    {
    public:
        Threadpool(size_t, size_t);
        ~Threadpool();

        void start();
        void stop();
        void addTask(Task &&);
    private:
        Task getTask();
        void threadFunc();

    private:
        size_t _capacity;
        size_t _queuesize;
        std::vector<std::unique_ptr<Thread>> _threads;
        TaskQueue _taskqueue;
        bool _isExit;
    };
}

#endif